package edu.rutgers.moko.data.util;

import java.util.Arrays;
import java.util.List;

public enum ProtectedAccess {
	LOCATION("Location", "loc"), 
	AP("Access point", "ap"), 
	CLIENT("Client", "cl");
	
	private final String restriction;
	private final String field;
	
	private ProtectedAccess(String restriction, String field) {
		this.restriction = restriction;
		this.field = field;
	}
	
	public String restriction(){
		return restriction;
	}
	
	public String field(){
		return field;
	}
	
	public static List<ProtectedAccess> valuesAsList(){
		return Arrays.asList(ProtectedAccess.values());
	}
	
	public static ProtectedAccess getByField(String field) {
		ProtectedAccess result = null;
		if (field != null) {
			if ("loc".equals(field.toLowerCase())) {
				result = ProtectedAccess.LOCATION;
			}
			if ("ap".equals(field.toLowerCase())) {
				result = ProtectedAccess.AP;
			}
			if ("cl".equals(field.toLowerCase())) {
				result = ProtectedAccess.CLIENT;
			}
		}
		return result;
	}

}
